package com.itqf.service.impl;

import com.itqf.mapper.DtsOrderMapper;
import com.itqf.service.DtsOrderService;
import com.itqf.vo.CategorySellAmts;
import com.itqf.vo.DayStatis;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * projectName: sm_project
 *
 * @author: 赵伟风
 * time: 2021/7/14 17:17
 * description:
 */
@Service
public class DtsOrderServiceImpl implements DtsOrderService {

    public static final Logger logger = LoggerFactory.getLogger(DtsOrderServiceImpl.class);

    @Autowired
    private DtsOrderMapper dtsOrderMapper;

    /**
     * 查询指定之间内,类别的销售额
     *
     * @param days
     * @return
     */
    @Override
    public List<CategorySellAmts> queryOrderSell(int days) {

        if (days<= 0) {
            logger.error("[类别销售额]不能查询时间小于0的类别销售额!");
            return  null;
        }

        List<CategorySellAmts> categorySellAmts = dtsOrderMapper.queryCategorySell(days);

        logger.info("[类别销售额]业务查询成功!数据为:{}",categorySellAmts);

        return categorySellAmts;
    }



    /**
     * 查询天数内的订单销售额
     *
     * @param days
     * @return
     */
    @Override
    public List<DayStatis> queryDayOrderCell(int days) {

        if (days<= 0) {
            logger.error("[类别销售额]不能查询时间小于0的订单销售额!");
            return  null;
        }

        List<DayStatis> dayStatis =  dtsOrderMapper.queryDaySell(days);

        logger.info("[日常销售]每日销售额统计数据为:{}",dayStatis);
        return dayStatis;
    }
}
